/* 设备管理-基础设置api */

import { ajaxService } from '@/utils/request';

const env = import.meta.env;
// let baseURL = env.VITE_API_BASE_URL;
let baseURL = env.VITE_EQUIPMENT_URL;
let baseURL1 = env.VITE_YUANTAO_SHENGCHAN_URL;
// let baseURL1 = env.VITE_EQUIPMENT_URL; // 元涛

// 获取设备类型数据
export function GetEquipmentType() {
  return ajaxService({
    url: '/equipment/set/type',
    method: 'get',
    baseURL,
  });
}

// 新增设备类型数据
export function PostEquipmentType(data: any) {
  return ajaxService({
    url: '/equipment/set/type',
    method: 'post',
    baseURL,
    data,
  });
}

// 修改设备类型数据
export function PutEquipmentType(data: any) {
  return ajaxService({
    url: '/equipment/set/type',
    method: 'post',
    baseURL,
    data,
  });
}

// 修改设备类型数据
export function DelEquipmentType(params: any) {
  return ajaxService({
    url: '/equipment/set/type',
    method: 'delete',
    baseURL,
    params,
  });
}

// 获取设备故障类别数据
export function GetEquipmentFaultType(params: any) {
  return ajaxService({
    url: '/equipment/set/type/state',
    method: 'get',
    baseURL,
    params,
  });
}

// 添加或修改设备故障类别数据
export function PostEquipmentFaultType(data: any) {
  return ajaxService({
    url: '/equipment/set/type/state',
    method: 'post',
    baseURL,
    data,
  });
}

// 删除设备故障类别数据
export function DelEquipmentFaultType(params: any) {
  return ajaxService({
    url: '/equipment/set/type/state',
    method: 'delete',
    baseURL,
    params,
  });
}

// 获取设备使用状态设置
export function GetEquipmentState(params: any) {
  return ajaxService({
    url: '/equipment/set/type/state',
    method: 'get',
    baseURL,
    params,
  });
}

// 添加或修改使用状态设置
export function PostEquipmentState(data: any) {
  return ajaxService({
    url: '/equipment/set/type/state',
    method: 'post',
    baseURL,
    data,
  });
}

// 删除使用状态设置
export function DelEquipmentState(params: any) {
  return ajaxService({
    url: '/equipment/set/type/state',
    method: 'delete',
    baseURL,
    params,
  });
}

// 获取设备完好状态设置
export function GetEquipmentGoodState(params: any) {
  return ajaxService({
    url: '/equipment/set/type/state',
    method: 'get',
    baseURL,
    params,
  });
}

// 添加或修改设备完好状态数据
export function PostEquipmentGoodState(data: any) {
  return ajaxService({
    url: '/equipment/set/type/state',
    method: 'post',
    baseURL,
    data,
  });
}

// 删除完好状态设置
export function DelEquipmentGoodState(params: any) {
  return ajaxService({
    url: '/equipment/set/type/state',
    method: 'delete',
    baseURL,
    params,
  });
}

// 新增编号设置
export function postEquipmentNum(data: any) {
  return ajaxService({
    url: '/equipment/set/num/set',
    method: 'post',
    baseURL,
    data,
  });
}

// 新增编号设置
export function getEquipmentNum(params: any) {
  return ajaxService({
    url: '/equipment/set/num/set',
    method: 'get',
    baseURL,
    params,
  });
}

// 获取设备完好状态设置
export function GetCapacityLoads() {
  return ajaxService({
    url: '/equipment/set/capacityLoads',
    method: 'get',
    baseURL,
  });
}

// 修改设备完好状态设置
export function PutCapacityLoad(data: { id: number; value: number }) {
  return ajaxService({
    url: '/equipment/set/capacityLoad',
    method: 'put',
    data,
    baseURL,
  });
}

/**
 *
 * @param params 报废列表
 * @returns
 */
export function GetEquipmentScrappedPage(params: {
  /**
   * 设备名称模糊
   */
  equipName?: string;
  /**
   * 设备编码模糊
   */
  equipNumber?: string;
  page?: number;
  size?: number;
}) {
  return ajaxService({
    url: '/equipment/scrapped/page',
    method: 'GET',
    params,
    baseURL,
  });
}

/**
 *
 * @param params 新增设备报废
 * @returns
 */
export function PostEquipmentScrapped(data: {
  /**
   * 申请人名
   */
  applicant: string;
  /**
   * 确认人名
   */
  confirmer: string;
  /**
   * 设备id
   */
  equipmentId: number;
  /**
   * 备注
   */
  remark: string;
  /**
   * 报废理由
   */
  scrappedReason: string;
}) {
  return ajaxService({
    url: '/equipment/scrapped',
    method: 'POST',
    data,
    baseURL,
  });
}

/**
 *
 * @param params 修改设备报废
 * @returns
 */
export function PutEquipmentScrapped(data: {
  id: number;

  /**
   * 确认人名
   */
  confirmer: string;

  /**
   * 备注
   */
  remark: string;
  /**
   * 状态
   */
  status: number;
  /**
   * 确认时间

   */
  confirmAt: string;
}) {
  return ajaxService({
    url: '/equipment/scrapped',
    method: 'PUT',
    data,
    baseURL,
  });
}

/**
 *
 * @param params 设备报废详情
 * @returns
 */
export function GetEquipmentScrapped(params: { id: number }) {
  return ajaxService({
    url: '/equipment/scrapped',
    method: 'GET',
    params,
    baseURL,
  });
}

// 新增LOGO
export function PostflowCardlogo(data: any) {
  return ajaxService({
    url: '/produce/flowCardlogo',
    method: 'post',
    baseURL: baseURL1,
    data,
  });
}

// 获取LOGO
export function GetflowCardlogo() {
  return ajaxService({
    url: '/produce/flowCardlogos',
    method: 'get',
    baseURL: baseURL1,
  });
}
// 获取默认LOGO
export function GetflowCardlogoDef() {
  return ajaxService({
    url: '/produce/flowCardlogo',
    method: 'get',
    baseURL: baseURL1,
  });
}

// 修改默认LOGO
export function PutflowCardlogoDef(data: any) {
  return ajaxService({
    url: '/produce/defaultFlowCardlogo',
    method: 'put',
    baseURL: baseURL1,
    data,
  });
}
